<template>
    <section>
        <!--工具条-->
        <template v-if="is_search">
            <div class="searchgrid">
                <div style="float: right;">
                    <input v-model="post_data.search.stock_finance_id" style="width:120px;height:20px;"
                           value="" maxlength="10" type="text" placeholder="搜索:子账户ID">
                    <input v-model="post_data.search.stock_code" style="width:120px;height:20px;"
                           value="" maxlength="10" type="text" placeholder="搜索:证券代码">
                    <input v-model="post_data.search.stock_name" style="width:120px;height:20px;"
                           value="" maxlength="10" type="text" placeholder="搜索:证券名称">
                    <input v-model="post_data.has.client.search.cellphone" style="width:120px;height:20px;"
                           value="" maxlength="10" type="text" placeholder="搜索:客户手机号">
                  <input class="yl-input-button" value=" 查询 " type="button" v-on:click="search">
                </div>

            </div>
        </template>

        <!--列表-->
        <el-table :data="forms.list"
                  highlight-current-row
                  v-loading="loading"
                  style="width: 100%;">

            <el-table-column prop="stock_finance_id" label="子账户ID" show-overflow-tooltip></el-table-column>
            <el-table-column prop="client.cust_info" min-width="120px" label="客户信息" show-overflow-tooltip></el-table-column>
            <el-table-column prop="makedeal_date_time" min-width="130" label="成交日期" show-overflow-tooltip></el-table-column>
            <el-table-column prop="stock_code" label="证券代码" show-overflow-tooltip></el-table-column>
            <el-table-column prop="stock_name" label="证卷名称" show-overflow-tooltip></el-table-column>
            <el-table-column prop="sell_buy" label="买卖标志" show-overflow-tooltip></el-table-column>
            <el-table-column prop="make_deal_status" label="成交状态" show-overflow-tooltip></el-table-column>
            <el-table-column prop="makedeal_price" label="成交单价" show-overflow-tooltip></el-table-column>
            <el-table-column prop="makedeal_quantity" label="成交数量" show-overflow-tooltip></el-table-column>
            <el-table-column prop="makedeal_amount" label="成交金额" show-overflow-tooltip></el-table-column>
            <el-table-column prop="stock_finance_entrust_id" label="委托ID" show-overflow-tooltip></el-table-column>
            <el-table-column prop="id" label="成交ID" show-overflow-tooltip></el-table-column>
            <el-table-column v-if="isUserSystemAdmin" prop="parent_stock_finance_id" label="母账户ID" show-overflow-tooltip></el-table-column>
            <el-table-column v-if="isUserSystemAdmin" prop="parent_entrust_id" label="委托编号" show-overflow-tooltip></el-table-column>
            <el-table-column v-if="isUserSystemAdmin" prop="parent_makedeal_id" label="成交编号" show-overflow-tooltip></el-table-column>
        </el-table>

        <!--工具条-->
        <div class="pagination">
            <el-col :span="24" class="toolbar">
                <el-pagination
                        @size-change="changeSize"
                        @current-change="pageChange"
                        :current-page="post_data.offset/post_data.limit+1"
                        :page-sizes="[15, 30, 45, 60]"
                        :page-size="post_data.limit"
                        layout="total, sizes, prev, pager, next, jumper"
                        :total="forms.count"
                        style="float:left;">
                </el-pagination>
            </el-col>
        </div>
    </section>
</template>

<script>
    import {getUStockFinanceDayMakedeals} from '../../../api/trade';
    export default {
        props: ['sfid', 'no_search'],
        data() {
            return {
                is_search: true,
                loading: false,
                forms: {},
                post_data: {
                    field: ['id', 'cust_id', 'stock_finance_id', 'stock_code', 'stock_name', 'sell_buy', 'make_deal_status',
                        'makedeal_price', 'makedeal_quantity', 'makedeal_amount', 'stock_finance_entrust_id',
                        'parent_stock_finance_id', 'parent_entrust_id', 'parent_makedeal_id', 'makedeal_date',
                        'makedeal_time', '"" as makedeal_date_time'],
                    search: {
                        stock_finance_id: '',
                        stock_code: '',
                        stock_name: '',
                    },
                    where: {
                        stock_finance_id: this.sfid,
                    },
                    count: true,
                    offset: 0,
                    limit: 15,
                    client: {
                        field: ['id', 'nick_name', 'cellphone', '"" as cust_info']
                    },
                    has: {
                        client: {
                            search: {
                                cellphone: ''
                            }
                        }
                    },
                    order: 'id desc'
                }
            }
        },
        created(){
            if (this.sfid) this.is_search = false;
            this.getList();
        },
        methods: {
            getList: function () {
                this.loading = true;
                getUStockFinanceDayMakedeals(this.post_data).then(res => {
                    this.loading = false;
                    if (res.status === 0) return this.ezNotifyAxiosThen(res);
                    this.forms = res.data;
                }).catch(error => this.ezNotifyAxiosCatch(error));
            },
            pageChange: function (index) {
                this.post_data.offset = (index - 1) * this.post_data.limit;
                this.getList();
            },
            changeSize: function (num) {
                this.post_data.offset = 0;
                this.post_data.limit = num;
                this.getList();
            },
            search: function () {
                this.post_data.offset = 0;
                this.getList();
            }
        }
    }
</script>

<style scoped>
</style>
